<script setup lang="ts">
import { ref, watch } from 'vue';

  const totalCount = ref(10)
  const message = ref('hello!')

  watch(totalCount,()=>{
    console.log('数据被侦听到了')
  })

  watch([totalCount,message],(newValue,oldValue)=>{
    console.log('totalCount:数据被侦听到了')
    console.log('message:打招呼了')
    console.log({newValue,oldValue})
  })
</script>


<template>
 <p>计数器：{{ totalCount }}</p>
 <button @click="totalCount++">点击+1</button>
 <button @click="message=message+'!'">持续打招呼</button>
</template>


